import { request } from "../../request/index"
import api from '../../api/index'
const app = getApp()
Page({
    onShareAppMessage: function () {
        return {
            title: "分享小程序",
            path: '/pages/home/home',
            imageUrl: ''
        }
    },
    // 数据定义
    data: {
        swiperList: [
            {
                img: "/icons/study.jpeg"
            },
            {
                img: "/icons/study.jpeg"
            },
            {
                img: "/icons/study.jpeg"
            }
        ],
        acc: 0,
        finish: 0,
        unfinish: 0
    },

    // 页面开始加载就会触发
    onLoad: function (options) {
        // 函数调用
        // this.getSwiperList()
        // let userid = wx.getStorageSync('userID')
        // wx.request({
        //  url: app.globalData.baseUrl+`/record/selectAcc/${userid}`,
        //  method:"GET",
        //  success:(res)=>{
        //      console.log(res);
        //  }
        // })
    },

    onShow: function () {
        let user = wx.getStorageSync('user')
        this.gethandData()
    },

    async gethandData() {
        let userid = wx.getStorageSync('userID')
        // await request({
        //     url: app.globalData.baseUrl + `/record/selectAcc/${userid}`
        // }).then((res) => {
        //     console.log(res);
        //     let data = res.data
        //     this.setData({
        //         acc: data.acc,
        //         finish: data.finish,
        //         unfinish: data.unfinish
        //     })
        // })
        await api.gethanddata(userid).then(res=>{
            let data = res.data
                this.setData({
                    acc: data.acc,
                    finish: data.finish,
                    unfinish: data.unfinish
                })
        })
    },

    jump(e) {
        // console.log(e);
        let userID = wx.getStorageSync('userID')
        if (userID) {
            wx.navigateTo({
                url: '/subpkg/moni/moni',
            })
        }
        else {
            wx.showToast({
                title: '请先登录',
                icon: 'none',
                duration: 2000
            })
        }

    },

    jump2(e) {
        // console.log(e);
        let userID = wx.getStorageSync('userID')
        if (userID) {
            wx.navigateTo({
                url: '/subpkg/tixing/tixing',
            })
        }
        else {
            wx.showToast({
                title: '请先登录',
                icon: 'none',
                duration: 2000
            })
        }

    },


    jumpshouchang(e) {
        // console.log(e);
        let userID = wx.getStorageSync('userID')
        if (userID) {
            wx.navigateTo({
                url: '/shouchang/shouchang/index',
            })
        }
        else {
            wx.showToast({
                title: '请先登录',
                icon: 'none',
                duration: 2000
            })
        }

    },

    jumpcuoti(e) {
        // console.log(e);
        let userID = wx.getStorageSync('userID')
        if (userID) {
            wx.navigateTo({
                url: '/shouchang/cuoti/index',
            })
        }
        else {
            wx.showToast({
                title: '请先登录',
                icon: 'none',
                duration: 2000
            })
        }

    },
})